/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rule;

/**
 *
 * @author Daniel Gribel
 */
public class AtLeastOneNumber extends Clause {

    public AtLeastOneNumber(String p) {
        super(p);
        super.setLog("5 points for at least one number");
    }    
    
    @Override
    public boolean checkConditions() {
        for (char a : getPass().toCharArray()) {
            if (Character.isDigit(a)) {
                punctuate(5);
                return true;
            }
        }
        return false;
    }

    @Override
    public String outputMessage() {
        return getLog();
    }
    
    public int count(){
        int count = 0;
        
        for (char a : getPass().toCharArray()) {
            if (Character.isDigit(a))
                count++;
        }
        return count;
    }
        
}
